Skip to content

Fix filtering with negated labels#28455

Draft
simonbrauner wants to merge 1 commit intocontainers:mainfrom
simonbrauner:fix-filtering-with-negated-labels
Draft

Fix filtering with negated labels#28455
simonbrauner wants to merge 1 commit intocontainers:mainfrom
simonbrauner:fix-filtering-with-negated-labels

Conversation

@simonbrauner
Copy link
Copy Markdown
Contributor

@simonbrauner simonbrauner commented Apr 7, 2026

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?


While working on #28413, I found out that when filtering based on labels, the label filters are combined with AND, while label! filters are combined with OR. I thought it would make more sense to handle both labels with the same operation, as it would be unexpected otherwise, and the way it looks in the code return !filters.MatchLabelFilters(filterValues, v.Labels()) makes it seem like a bug.

Currently, for podman this works correctly in images, and incorrectly for containers, volumes, and pods.

This is a breaking change and it may make podman more inconsistent with docker.

It looks like for docker, label! has the same problem in volume prune, so I reported it docker/cli#6918.

Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant